package com.liujit.generator.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Description db字段类型映射
 * @Author LiuJun
 * @Date 2020/8/13 5:32 下午
 */
@Getter
@AllArgsConstructor
public enum DbColumnType {
    DECIMAL("decimal", "BigDecimal"),
    TIME("time", "Date"),
    DATE("date", "Date"),
    TEXT("text", "String"),
    LONG_TEXT("longtext", "String"),
    BIGINT("bigint", "Long"),
    VARCHAR("varchar", "String"),
    SMALLINT("smallint", "Short"),
    DATETIME("datetime", "Date"),
    INTEGER("integer", "Integer"),
    INT("int", "Integer"),
    JSON("json", "Object");

    private final String dataType;

    private final String type;

    public static DbColumnType get(String dataType) {
        for (DbColumnType ele : values()) {
            if (ele.getDataType().equals(dataType)) {
                return ele;
            }
        }
        return null;
    }
}
